<template>
  <HPopup style="height: fit-content; min-height: 0" cancel-text="取消" v-model:show="innerShow" :actions="actions">
  </HPopup>
</template>
<script setup>
import HPopup from '@comp/HPopup/HPopup.vue';
import {closePopup, createProps} from '@/utils';
import {computed, nextTick} from 'vue';

defineOptions({name: 'SelectRelationConfig'});

const props = defineProps({
  show: createProps(Boolean),
  modelValue: createProps(Object),
  manualConfigs: createProps(Array),
});
const emits = defineEmits(['update:show', 'update:modelValue', 'ok']);

const innerShow = computed({
  get() {
    return props.show;
  },
  set(v) {
    emits('update:show', v);
  },
});
const actions = computed(() => {
  return (props.manualConfigs || []).map(item => {
    let actionName = item?.manual?.manualSelectorButtonName;

    return {
      name: actionName,
      callback: () => {
        emits('update:modelValue', item);
        nextTick(() => {
          closePopup();
          setTimeout(() => {
            emits('ok');
          }, 200)
        })
      }
    }
  })
})
</script>
<style scoped lang="less">

</style>